<template>
  <div>
    <input type="text" v-model="pwd" />
        <button @click="loginFunc">登录</button>
    </div>
</template>


<script setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'
import {useStore} from 'vuex'
 const router= useRouter()
 const store=useStore()
 const pwd=ref('')
const loginFunc=()=>{

  window.sessionStorage.setItem('token',pwd.value)
  if(pwd.value=='admin'){
  store.commit('changeLoginState',true)
  router.push({path:"/todolist"})
  }else{
    alert('pwd wrong!!')
  }

}
</script>